//扩展 返回顶部
/*
	示例：$().backToTop();
*/
(function($){
	//公开的
	$.fn.backToTop = function(options) { 
		var ele = $(this);//焦点对象
		var settings = {
			cssname:'backToTop',//css样式 name
			tit:'',//焦点框
			src:'',//背景图路径 空为默认
			w:23,//宽
			h:72,//高
			bottom:100,
			opacity:0.5,
			speed:120,//速度
			};
		settings = $.extend(settings,options);

		var $backToTopTxt = settings.tit,
		$backToTopEle = $('<style type="text/css">/*返回顶部css*/.'+ settings.cssname +'{display:none;background:url('+ settings.src +')no-repeat 0 0;width:'+ settings.w +'px;height:'+ settings.h +'px;line-height:1.2;padding:5px 0;color:#fff;font-size:12px;text-align:center;position:fixed;_position:absolute;right:10px;bottom:'+ settings.bottom +'px;_bottom:"auto";cursor:pointer;opacity:'+ settings.opacity +';filter:Alpha(opacity='+ settings.opacity*100 +');}.'+ settings.cssname +':hover{opacity: 100;filter: Alpha(opacity=100);}</style><div class="'+ settings.cssname +'"></div>').appendTo($("body")).text($backToTopTxt).attr("title", $backToTopTxt).click(function() {
			$("html, body").animate({
				scrollTop: 0
			},
			settings.speed);
		}),
		$backToTopFun = function() {
			var st = $(document).scrollTop(),
			winh = $(window).height(); (st > 0) ? $backToTopEle.show() : $backToTopEle.hide();
			if (!window.XMLHttpRequest) {
				$backToTopEle.css("top", st + winh - 166);
			}
		};
		$(window).bind("scroll", $backToTopFun);
		$(function() {
			$backToTopFun();
		});
	}
})(jQuery);